package git.bankview.wl.report;

import java.util.*;
import java.sql.*;
import java.io.*;

import laya.semi.process.*;

import git.bankview.sl.db.*;
import git.bankview.sl.report.ReportCommon;

import org.apache.log4j.Logger;

public class JasperPropertiesGetter
	implements IGenericClassActivity
{
	private static Logger log = Logger.getLogger(JasperPropertiesGetter.class);
	
	private static final String SQL_SELECTOR = "select strvalue, propindex from dqreportprop where transid = ? and propname = ? order by propindex";
	
	public void execute(IProcessContext oCtx)
		throws Exception
	{
		String[] vPropName = oCtx.getActivityParameter().split(":");
		String oTransid = (String)oCtx.getField("transid");
		
		Connection oConn = DBConnectionFactory.getCoreConnection();
		try
		{
			PreparedStatement ps = oConn.prepareStatement(SQL_SELECTOR);
			
			for (int i = 0; i < vPropName.length; ++i)
			{
				ps.setString(1, oTransid);
				ps.setString(2, vPropName[i]);
				
				ResultSet rs = ps.executeQuery();
				Vector v = new Vector();
				while(rs.next())
				{
					v.addElement(rs.getString(1));
				}
				oCtx.setField(vPropName[i], v.toArray(new String[0]));
			}
		}
		finally
		{
			oConn.close();
		}
	}
}
